package com.rrjjg.app.core.config;

import com.rrjjg.app.core.interceptor.LoginInterceptor;
import com.rrjjg.app.core.interceptor.SignInterceptor;
import com.rrjjg.app.core.interceptor.SpringMvcConfig;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ----------------------------------------------------------------------------- <br>
 * 功能 :  <br>
 * ----------------------------------------------------------------------------- <br>
 * 作者 : Vayne <br>
 * 时间 : 2023/4/12 <br>
 */
@Configuration(enforceUniqueMethods = false)
public class MvcConfig {


    @Bean
    public LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }

    @ConditionalOnMissingBean(SignInterceptor.class)
    @Bean
    public SpringMvcConfig springMvcConfig(LoginInterceptor loginInterceptor) {
        return new SpringMvcConfig(loginInterceptor);
    }

    @ConditionalOnBean(SignInterceptor.class)
    @Bean
    public SpringMvcConfig springMvcConfig(LoginInterceptor loginInterceptor, SignInterceptor signInterceptor) {
        return new SpringMvcConfig(loginInterceptor, signInterceptor);
    }
}
